<template>
  <div class="mainDiv">
    <div class="myWarning">VIP用户专享特权，从“浙江省普通高校高职招生考试信息管理系统”中导出志愿填报pdf表，导入到本系统中，提早知道自己的上线情况。</div>
    <div class="padlr10" v-if="$root.userInfo && $root.userInfo.vip_level">
      <iframe name="iframe_0" style="position:absolute;top:-9999px">
      </iframe>
      <form name="form" novalidate method="post" enctype="multipart/form-data" target="iframe_0" action="/auth/uploadIntentions" style="position:absolute;top:-9999px">
        <div class="padlr10">
          <label class="control-label">志愿表：</label>
          <input type="file" name="file" id="xmlInput" @change="uploadIntentions()"
                 accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf" required>
        </div>
      </form>
      <mt-button size="large" type="primary" @click="triggerFile()">上传志愿表</mt-button>
    </div>

    <div v-if="major.id">
      <div style="color: #26A2FF;padding-left:15px;margin-top: 15px;">您的上线情况如下：</div>
      <mt-cell :title="major.school_name"  >
        <span>{{major.full_name}}</span>
      </mt-cell>
    </div>
  </div>
</template>

<script>
  import { Toast,Indicator } from 'mint-ui';
    export default {
        name: "knowEarly",
        data(){
          return {
            major:{}
          }
        },
        methods:{
          triggerFile:function(){
            $('#xmlInput').click();
          },
          uploadIntentions:function(){
            let vm = this;
            if(document.getElementById("xmlInput").value== null){
              Toast("请选择志愿表！")
              return false;
            }
            Indicator.open({
              text: '正在查询，请耐心等候...',
              spinnerType: 'fading-circle'
            });
            $("iframe[name='iframe_0']").on("load",function() {
              Indicator.close();
              var contents = $(this).contents().get(0);
              var data = $(contents).find('body').text();
                data = window.eval('(' + data + ')');
              if (data.code === 0) {
                if(data.data){
                  vm.major = data.data;
                  Toast("恭喜您!您超过"+vm.major.school_name+"的专业:"+vm.major.full_name+"的分数线!");
                }else{
                  Toast("对不起!您落榜了");
                }
              } else{
                Toast(data.msg);
              }
            });

            $("form[name='form']").submit();
          }
        }
    }
</script>

<style scoped>
  .myWarning{
    padding: 15px;
    background-color:#FFFADE;
    color: #FC5831;
    font-size: 15px;
  }
</style>
